// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using SnapObjects.Commons;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Defines a select list in the model class, to decide which columns to be selected from the result set. 
    ///     The select list is a series of expressions separated by commas. Multiple SqlSelectTable attributes can 
    ///     be applied to one model class.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = true)]
    public class SqlSelectAttribute : Attribute, ISqlSelect
    {
        /// <summary>
        ///     Initializes a new instance of the SqlSelectAttribute class.
        /// </summary>
        /// <param name="selectName">The name of the select list.</param>
        public SqlSelectAttribute(string selectName)
        {
            this.SelectName = selectName;

            Check.NotEmpty(selectName, nameof(selectName));
        }

        /// <summary>
        ///    Gets the name of the select list. 
        /// </summary>
        public string SelectName { get; }

        /// <summary>
        ///     Gets or sets the raw SQL select list that decides which columns to be selected from the result set.
        /// </summary>
        public string RawSelect { get; set; }
    }
}
